import java.util.Arrays;
import java.util.Comparator;

public class Test02 {
    public static void main(String[] args) {
        GirlFriend[] gf=new GirlFriend[3];
        GirlFriend gf1=new GirlFriend(18,"xiaohuihui");
        GirlFriend gf2=new GirlFriend(19,"xiaodandan");
        GirlFriend gf3=new GirlFriend(19,"xiaoshishi");
        gf[0]=gf1;
        gf[1]=gf2;
        gf[2]=gf3;
        Arrays.sort(gf,new Comparator<GirlFriend>(){
            @Override
            public int compare(GirlFriend o1,GirlFriend o2){
                int temp=o1.getAge()-o2.getAge();
                temp=temp==0?o1.getName().compareTo(o2.getName()):temp;
                return temp;
            }
        });
        System.out.println(Arrays.toString(gf));
    }
}
